<template>
	<view class="">
		<view class="pd pt20  pm10 bgff display-flex fxxcvxcrtr">
			<view class=" flex-1 pr">
				<icon type="search" class="skjjxcerert" size="22"></icon>
				<input type="text" confirm-type="search" v-model="queryLike" @confirm="sskxsf" class="xjhsddfr"
					placeholder="请输入关键词进行搜索" />
			</view>
			<view class="ml20 pr">
				<icon class="iconfont icon-fenxiang fz36 cz z6"></icon>
				<button type="default" open-type="share" class="xzcdfrtrt"></button>
			</view>
		</view>

		<view class="bgff btm pd pm20  gfvcxrtrtytryu pr pt20" id="xcxzresx">
			<view class="  display-flex cen">
				<view class="flex-1 fz26 " @tap="xcvcxtryyt">
					<picker @change="jjxcza" :range="arraya">
						<view class="vertical-center">
							<view class="display-flex">
								<view class=" ">
									<view class="dsfxcvtrt dian ab">
										<text class="cz">{{arraya[unxczfa]||'推荐'}}</text>
									</view>

								</view>
								<view class="vertical-center ">
									<text class="iconfont icon-down fz24 ml10 kmxczxrt"></text>
								</view>
							</view>
						</view>
					</picker>
				</view>

				<view class="flex-1 fz26 display-flex" @tap="quyhzxczxre">
					<view class=" ">
						<view class="dsfxcvtrt dian">
							<text class="cz">{{unxczfb||'区域选择'}}</text>
						</view>
					</view>
					<view class="vertical-center ">
						<text class="iconfont icon-down fz24 ml10 kmxczxrt"></text>
					</view>
				</view>
				<view class="flex-1 fz26 " @tap="xcvcxtryyt">
					<picker @change="jjxczc" :range="arrayc">
						<view class="vertical-center">
							<view class="display-flex">
								<view class=" ">
									<view class="dsfxcvtrt dian ">
										<text class="cz">{{arrayc[unxczfc]||'企业选择'}}</text>
									</view>

								</view>
								<view class="vertical-center ">
									<text class="iconfont icon-down fz24 ml10 kmxczxrt"></text>
								</view>
							</view>
						</view>
					</picker>
				</view>

			</view>
			<view class="kkxczretxdr btm" v-if="kmmxsd">
				<diquxz @success="hejmxdfrf"></diquxz>
			</view>
		</view>




		<zwList :kxzcxfdf="kxzcxfdf"></zwList>

		<view class="xczcfrstrt" v-if="kmmxsd">

		</view>

	</view>
</template>
<script lang="ts" setup>
	import { ref } from "vue"
	import { hf, hfer, hfsan, dxrequest } from "@/util/index.js"
	import { wxlogin } from "@/util/dxwchar.js"
	import {
		onLoad,
		onPageScroll,
		onShow,
		onShareAppMessage,
		onReachBottom
	} from "@dcloudio/uni-app";
	import diquxz from "@/components/diquxz.vue"
	import zwList from "@/components/zwList.vue"
	const kmmxsd = ref()
	const arraya = ['推荐', '最新', '附近']
	const arrayc = ['全部']
	const arrayd = ['全部']
	const unxczfa = ref()
	const unxczfb = ref("区域选择")
	const unxczfc = ref("企业选择")
	const unxczfd = ref("工作类型")
	const dictValue = ref()
	const page = ref(1)
	const kmxczxcd = ref([])
	const kxzcxfdf = ref([])
	const queryLike = ref()
	const jnxcfd = ref({})
	const jmxcfb = ref({})
	const companyId = ref()
	const type = ref()
	const xczrerx = ref()
	onShareAppMessage(() => {
		return {
			title: '薪智直聘',
			path: '/pages/index/index'
		}
	})
	const jjxcza = (data) => {
		unxczfa.value = data.detail.value
		jnxcfd.value = {}
		if (data.detail.value == 0) {
			jnxcfd.value.orderField = "t.create_time"
			jnxcfd.value.order = "desc"
		}
		if (data.detail.value == 1) {
			jnxcfd.value.orderField = "t.is_good"
			jnxcfd.value.order = "desc"
		}
		if (data.detail.value == 2) {
			jnxcfd.value.lng = wzinfo.value.lng
			jnxcfd.value.lat = wzinfo.value.lat
		}
		page.value = 1
		kxzcxfdf.value = []
		zhiweik()
	}
	const jjxczc = (data) => {
		unxczfc.value = data.detail.value
		if (data.detail.value > 0) {
			companyId.value = xczrerx.value[data.detail.value - 1].id
		} else {
			companyId.value = ""
		}
		page.value = 1
		kxzcxfdf.value = []
		zhiweik()
	}
	const getcsList = async () => {
		const { data } = await dxrequest("/api/tmcompany/option")
		data.map(a => {
			arrayc.push(a.name)
		})
		xczrerx.value = data
	}
	const sskxsf = ()=>{
		page.value = 1
		kxzcxfdf.value = []
		zhiweik()
	}
	const jjxczd = (data) => {
		unxczfd.value = data.detail.value

		if (data.detail.value > 0) {
			type.value = kmxczxcd.value[data.detail.value - 1].dictValue
		} else {
			type.value = ""
		}
		page.value = 1
		kxzcxfdf.value = []
		zhiweik()
	}
	const quyhzxczxre = () => {
		uni.pageScrollTo({
			selector: "#xcxzresx"
		})
		kmmxsd.value = true
	}
	const xcvcxtryyt = () => {
		uni.pageScrollTo({
			selector: "#xcxzresx"
		})
	}
	const hejmxdfrf = (data) => {
		console.log(data)
		kmmxsd.value = false
		unxczfb.value = data
	}
	const zhiweik = async () => {
		const { data } = await dxrequest("/api/job/page", {
			limit: 10,
			page: page.value,
			type: dictValue.value,
			queryLike: queryLike.value,
			...jnxcfd.value,
			companyId: companyId.value,
		})
		data.list.map(a => {
			kxzcxfdf.value.push(a)
		})
		uni.stopPullDownRefresh();
	}
	onLoad((data) => {

		dictValue.value = data.dictValue
		queryLike.value = data.queryLike
		zhiweik()
		getcsList()
		uni.setNavigationBarTitle({
			title: data.title
		})
	})
	onReachBottom(() => {
		page.value++
		zhiweik()
	})
</script>

<style scoped>
	.xczcfrstrt {
		position: fixed;
	}
</style>